using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;

namespace QLThuChi.OtherForms
{
    #region Using
    using QLThuChi.Helpers;
    using QLThuChi.Models;
    using QLThuChi.Repositories;
    #endregion

    /// <summary>
    /// tuansl added: Search can bo qua cac thoi ki
    /// </summary>
    public partial class FrmTimKhachHang : DevComponents.DotNetBar.Office2007Form
    {
        public EventHandler Handler { get; set; }

        public FrmTimKhachHang()
        {
            InitializeComponent();
        }

        private void btnTim_Click(object sender, EventArgs e)
        {
            TransferDataInfo(this, new MyEvent(txtMaKhachHang.Text.Trim() + "#" + txtTenKhachHang.Text.Trim()));
        }

        /// <summary>
        /// tuansl added: function is used to transfer data when event would be raised
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void TransferDataInfo(object sender, MyEvent e)
        {
            this.Close();
            this.Handler(this, e);
        }   

        private void btnThoat_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void txtMaKhachHang_KeyPress(object sender, KeyPressEventArgs e)
        {
            // Only allow type number
            if (!char.IsNumber(e.KeyChar) && (Keys)e.KeyChar != Keys.Back)
            {
                e.Handled = true;
            }
        }
    }
}